#pragma once
#include <string>
#include <vector>
#include "afxdb.h"
using namespace std;

const string checkDBStr = "select* from master..sysdatabases where name = 'autoTestDBV4';";
const string checkTableAccountTStr = "select top 1 * from sysObjects where Id = OBJECT_ID(N'accountT') and xtype = 'U'";
const string checkTableRecordTStr = "select top 1 * from sysObjects where Id = OBJECT_ID(N'recordT') and xtype = 'U'";
const CString creatDBStr = L"create database autoTestDBV4;";
const CString useDBStr = L"use autoTestDBV4;";
//todo single instance
class myDB
{
public:
	static myDB& getSingleIns()
	{
		return db;
	}
	~myDB()
	{
		dbCon.Close();
	}
private:
	myDB()
	{
		initDB();
	}
	myDB(const myDB&);
	myDB operator= (const myDB&);
public:
	CDatabase dbCon;
	bool ifDBExist();
	void configODBC();
	int getAuthRight( string strName, string strPwd);
	void addAccount( string name, string pwd, string authright);
	int changePwd( string name, string oldpwd, string newpwd);
	void addRecordToDB(string pname, string time, string itemsn, string tester, string verifier, string testsetId, string isrevert, string result, string rec);
	string getRootPwd();
	bool isUserExist(string name);
	void initDB();
	bool checkIsObjExist(string checkStr);
	string getDBServer();
private:
	static myDB db;
};


